library CombatManeuvers initializer init requires LegacySystem, NightVisionGoggles

	private function CombatManeuversConditions takes nothing returns boolean
		return GetSpellAbilityId()=='A033' and udg_SectorClear==false
	endfunction

	private function CombatManeuvers takes nothing returns nothing
		local real x = GetUnitX(GetTriggerUnit())
		local real y = GetUnitY(GetTriggerUnit())
		local unit u2
		
		
		
		set u2 = CreateUnit(Player(11),'e00I',x,y,0.0) 
		
		call UnitAddAbility(u2, 'Aloc')
		call UnitAddAbility(u2, 'A07E')
		call UnitAddAbility(u2, 'A01T')
		call StartSound(gg_snd_CombatManeuvers)
		set udg_Lighting = true
		call SetNVGEnabled(false)
		
		call SetImmortalSpawnEnabled(false)
		call SetCrepitusSpawnEnabled(false)
		call SetGhoulSpawnEnabled(false)
		
		call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 2.0, "ReplaceableTextures\\CameraMasks\\DreamFilter_Mask.blp", 100.0, 100.0, 100.0, 75.0 )
		call PolledWait(11.25)
		call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 3.0, "ReplaceableTextures\\CameraMasks\\DreamFilter_Mask.blp", 100.0, 100.0, 100.0, 75.0 )
		call RemoveUnit(u2)
		call PolledWait(3.75)
		set udg_Lighting = false
		call IntermissionRestore()
		set udg_Lighting = true
		call TriggerSleepAction(0.)
		call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 0.001, "ReplaceableTextures\\CameraMasks\\DreamFilter_Mask.blp", 100.0, 100.0, 100.0, 75.0 )
		call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 0.001, "ReplaceableTextures\\CameraMasks\\DreamFilter_Mask.blp", 100.0, 100.0, 100.0, 75.0 )
		call TriggerSleepAction(0.)
		set udg_Lighting = false
		call IntermissionRestore()
		call SetNVGEnabled(true)
		
		call SetImmortalSpawnEnabled(true)
		call SetCrepitusSpawnEnabled(true)
		call SetGhoulSpawnEnabled(true)
		set u2 = null
	endfunction

	private function init takes nothing returns nothing
		local trigger t
		set t = CreateTrigger()
		call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
		call TriggerAddCondition(t,Condition(function CombatManeuversConditions))
		call TriggerAddAction(t,function CombatManeuvers)
	endfunction

endlibrary